/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.jfonia.commands;

import org.jfonia.model.ISequence;
import org.jfonia.model.elements.MusicalElement;

/**
 *
 * @author Rik Bauwens
 */
public class AddMusicalElementCommand extends Command
{
        private ISequence sequence;
        private int tick;
        private MusicalElement musicalElement;
        private MusicalElement temporaryMusicalElement;

        public AddMusicalElementCommand(ISequence sequence, int tick, MusicalElement musicalElement)
        {
                super();
                this.sequence = sequence;
                this.tick = tick;
                this.musicalElement = musicalElement;
        }

        @Override
        protected void execute()
        {
                temporaryMusicalElement = musicalElement.clone();
                sequence.insertMusicalElement(tick, temporaryMusicalElement);
        }

        @Override
        protected void undo()
        {
                sequence.removeMusicalElement(temporaryMusicalElement);
        }
}
